import 'package:flutter_map/src/gestures/positioned_tap_detector_2.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
import 'package:situation/data/request/base_request.dart';

import 'state.dart';

class MapPointSelectController extends GetxController {
  final MapPointSelectState state = MapPointSelectState();

  void mapOnTap(TapPosition tapPosition, LatLng point)async {
    state.point = point;

    // todo  逆地址解析
    state.mapLatlonDto = await BaseRequest.getPositionName(point.latitude, point.longitude);
  }




  void onSave() {
    if(state.point.latitude == 0 || state.point.longitude == 0){
      SmartDialog.showNotify(msg: '请选择地理位置', notifyType: NotifyType.failure);
      return;
    }
    Get.back(result: state.mapLatlonDto);
  }
}
